package com.concurrency.example.commonUnSafe;

import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Vector;

@Slf4j
public class VectorExample {
    private static List list = new Vector();

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            list.add(i);
        }

        Thread thread1 = new Thread(){
            public void run(){
                for (int i = 0; i < 10; i++) {
                    list.remove(i);
                }
            }
        };

        Thread thread2 = new Thread(){
            public void run(){
                for (int i = 0; i < 10; i++) {
                    log.info("{}",list.get(i));
                }
            }
        };
        thread1.start();
        thread2.start();
    }
}
